package com.mini.framework.communicate.mina.handler;

import com.mini.framework.communicate.mina.protocol.Msg;

public class MsgHandlerThread implements Runnable {
	
	private HandlerFactory handlerFactory;
	
	private Msg msg;
	
	
	public MsgHandlerThread(HandlerFactory handlerFactory,Msg msg){
		this.handlerFactory = handlerFactory;
		this.msg = msg;
	}

	public void run() {
		Handler handler = handlerFactory.getHandler(msg);
		try{
			if(handler != null){
				handler.handle(msg);
			}
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			handler = null;
			this.msg = null;
		}
			
	}

}
